#include <iostream>
#include <set>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    set<int> val;
    for (int i = 0; i < n + m; ++i)
    {
        int x;
        cin >> x;
        val.insert(x);
    }
    for (const auto& z : val)
    {
        cout << z << ' ';
    }
    cout << endl;
    return 0;
}
